<?
require 'inc_security.php';
require('../../../functions/functions_getlink.php');
$action = getValue('action','str','POST','');
$domain = 'http://base.vcamp.vn';
switch($action){
    case 'searchpartners':
        $keyword = getValue('keyword', 'str', 'POST','');
        $data = array(
            'response' => 'false',
        );
        $url = $domain.'/home/vcampsan.php?action=searchpartners&keyword='.$keyword;
        $content = curl_get_content($url);
        $content = json_decode($content, true);
        if(!empty($content)){
            $data['response'] = 'true';
            foreach($content as $key => $value){
                $data['message'][] = array(
                    'label' => $value['com_name'],
                    'value' => $value['com_name'],
                    'com_id' => $value['com_id'],
                    'href' => $value['href'],
                    'logopath' => $value['logopath'],
                );
            }
        }
        print json_encode($data);
    break;
    case 'searchexperts':
        $keyword = getValue('keyword', 'str', 'POST','');
        $data = array(
            'response' => 'false',
        );
        $url = $domain.'/home/vcampsan.php?action=searchexperts&keyword='.$keyword;
        $content = curl_get_content($url);
        $content = json_decode($content, true);
        if(!empty($content)){
            $data['response'] = 'true';
            foreach($content as $key => $value){
                $data['message'][] = array(
                    'label' => $value['peo_name'],
                    'value' => $value['peo_name'],
                    'peo_id' => $value['peo_id'],
                    'href' => $value['href'],
                    'image' => $value['image'],
                    'role' => $value['role'],
                    'com_name' => $value['com_name'],
                    'com_href' => $value['com_href'],
                );
            }
        }
        print json_encode($data);
    break;
}
exit;
?>